package com.cincc.cinccimdemo.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.cincc.im.core.IMSipPhoneCtrl;
import com.cincc.im.model.CollectModel;

import java.util.List;

public class FavoriteViewModel extends ViewModel {
    private MutableLiveData<List<CollectModel>> favoriteListLiveData;


    public MutableLiveData<List<CollectModel>> favoriteListLiveData() {
        if (favoriteListLiveData == null) {
            favoriteListLiveData = new MutableLiveData<>();
        }
        IMSipPhoneCtrl.getInstance().getCollectList(0, imResponse -> {
            if (imResponse.getCode() == 0) {
                List<CollectModel> list = (List<CollectModel>) imResponse.getData();
                favoriteListLiveData.postValue(list);
            }
        });
        return favoriteListLiveData;
    }
}
